﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ShareMarking.Entity;
using ShareMarking.Service;
using System.Text;

namespace ShareMarking.ShowqrCode
{
    public partial class show : System.Web.UI.Page
    {
        public string nccode = "";
        public string ncname = "";
        public string code_url = "";
        public string mobile = "离职员工";

        public string nclcode = "离职员工";
        public string nclname = "离职员工";
        public string nclmobile = "离职员工";

        public string shopcode = "";
        public string shopname = "";
        public string shophtml = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            nccode = ComLib.QueryStringHelper.GetFormString("nccode");
            shopcode = ComLib.QueryStringHelper.GetFormString("shop_code");
            shopname = System.Web.HttpUtility.UrlDecode(ComLib.QueryStringHelper.GetFormString("shop_name"));

            shownc();
            showshop(shopcode, shopname);
        }

        private void showshop(string shopcode, string shopname)
        {
            StringBuilder strhtml = new StringBuilder ();
            string[] codelist = shopcode.Split(',');
            string[] namelist = shopname.Split(',');

            int count = (codelist.Length >= namelist.Length) ? namelist.Length : codelist.Length;   //取少的

            for (int i = 0; i < count; i++)
            {
                strhtml.Append("<dl><dt>"+namelist[i] + '(' + codelist[i] + ")</dt></dl>");
            }

            shophtml = strhtml.ToString();
        }

        private void shownc()
        {
            string nccode = ComLib.QueryStringHelper.GetFormString("nccode");
            nc_ncuser nc = nc_ncuserService.Instance.Get_SingleEntity_byWhere(nc_ncuser._.nc_code == nccode);
            if (nc != null)
            {
                qr_QrCodeRelate relate = qr_QrCodeRelateService.Instance.Get_SingleEntity_byWhere(
                    qr_QrCodeRelate._.rel_Code == nccode && qr_QrCodeRelate._.IsDelete == false);
                if (relate != null)
                {
                    qr_QrCode qr = qr_QrCodeService.Instance.Get_SingleEntity_byWhere(qr_QrCode._.scene_id == relate.qr_Scene_ID);
                    if (qr != null)
                    {
                        ncname = nc.name;
                        code_url = qr.qrcode_url;
                        mobile = nc.tel;
                        nclcode = nc.ncl_code;
                        nclname = nc.ncl_name;
                        nclmobile = nc.ncl_tel;
                    }
                }
            }
        }
    }
}